<template>
	<view v-if="!isccccc">
		<u-navbar :is-back="true" title="我的提问"></u-navbar>
		<!-- <view style="width: 100%;padding-bottom: 0rpx;">
			<u-tabs :list="listpaixu" :is-scroll="false" :current="currentpaixu" @change="changepaixu"></u-tabs>
		</view> -->
		<scroll-view class="VerticalMain" scroll-y scroll-with-animation :style="[{'height':viewitwm}]">
			<view class="" v-for="(item,index) in list" :key="index" :id="'main-'+index">
				<view class="cu-list">
					<view class="cu-item" @click="detail(item)">
						<view class="qes flex" style="margin-bottom: 30rpx;">
							<image src="../../static/img/sign-question.png" mode="widthFix" style="width: 62rpx;">
							</image>
							<view>{{item.content}}</view>
						</view>

						<view class="fuhao u-flex u-row-between">
							<!-- <view class="">{{fomatTime(item.createTime)}}</view> -->
							<view>
								<!-- <text class="cuIcon-attention text-grey"></text> -->
								<text
									style="font-size: 20rpx;margin-right: 10rpx;">问题发布于{{fomatTime(item.createTime)}}</text>
								<u-icon name="eye" color="#2979ff" size="32"></u-icon>
								<text class="margin-right">{{item.chakannum?item.chakannum:0}}</text>
								<u-icon name="chat" color="#2979ff" size="32" style="margin-left: 10rpx;"></u-icon>
								<text class="margin-right">{{item.detailNum?item.detailNum:0}}</text>
								<!-- <text class="cuIcon-attention text-grey"></text>
								<text class="margin-right">{{item.dianzan?item.dianzan:0}}</text>
								<text class="cuIcon-attention text-grey margin-right"></text>
								<text>{{item.shoucang?item.shoucang:0}}</text> -->
							</view>

						</view>
						<view style="position: absolute; right: 10rpx;bottom: 20rpx;font-size: 22rpx;" class="text-green"
							v-if="item.appointUser">指定{{item.appointUserInfo.nickName}}回答</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		http,
		Method
	} from "@/utils/request.js";
	import moment from 'dayjs';
	import storage from "@/utils/storage.js";
	export default {
		data() {
			return {
				listpaixu: [{
					name: '全部问题'
				}],
				currentpaixu: 0,
				huidashu: 0,
				viewitwm: "0px",
				list: [],
				// list: [{
				// 		"id": 1,
				// 		"qes": "我们单位买了一辆车，原价值26万，已计提折旧14万，卖价为4万，公司要求要做转账...",
				// 		"ans": "1.固定资产转入清理：借：累计折旧 固定资产减值准备（如计提）固定资产清理贷：固定资产原值报...",
				// 		time: "20小时前发布",
				// 		eye: 10,
				// 		like: 200,
				// 		comment: 21,
				// 	},
				// 	{
				// 		"id": 2,
				// 		"qes": "我们单位买了一辆车，原价值26万，已计提折旧14万，卖价为4万，公司要求要做转账...",
				// 		"ans": "1.固定资产转入清理：借：累计折旧 固定资产减值准备（如计提）固定资产清理贷：固定资产原值报...",
				// 		time: "20小时前发布",
				// 		eye: 10,
				// 		like: 200,
				// 		comment: 21,
				// 	},
				// 	{
				// 		"id": 2,
				// 		"qes": "我们单位买了一辆车，原价值26万，已计提折旧14万，卖价为4万，公司要求要做转账...",
				// 		"ans": "1.固定资产转入清理：借：累计折旧 固定资产减值准备（如计提）固定资产清理贷：固定资产原值报...",
				// 		time: "20小时前发布",
				// 		eye: 10,
				// 		like: 200,
				// 		comment: 21,
				// 	},
				// 	{
				// 		"id": 2,
				// 		"qes": "我们单位买了一辆车，原价值26万，已计提折旧14万，卖价为4万，公司要求要做转账...",
				// 		"ans": "1.固定资产转入清理：借：累计折旧 固定资产减值准备（如计提）固定资产清理贷：固定资产原值报...",
				// 		time: "20小时前发布",
				// 		eye: 10,
				// 		like: 200,
				// 		comment: 21,
				// 	},
				// 	{
				// 		"id": 2,
				// 		"qes": "我们单位买了一辆车，原价值26万，已计提折旧14万，卖价为4万，公司要求要做转账...",
				// 		"ans": "1.固定资产转入清理：借：累计折旧 固定资产减值准备（如计提）固定资产清理贷：固定资产原值报...",
				// 		time: "20小时前发布",
				// 		eye: 10,
				// 		like: 200,
				// 		comment: 21,
				// 	},
				// ],
				tabCur: 0,
				mainCur: 0,
				verticalNavTop: 0,
				load: true,
				title: "推荐问答",
				pageNumber: 1,
				pageSize: 20,
				isccccc:true,
			};
		},
		onReachBottom() {
			let page = this.page + 1;
			if (page * this.pagesize > this.total) {
				uni.showToast({
					icon: "none",
					title: "没有更多了"
				});
				return;
			}
			this.page = page;
			this.getMy();
		},
		onLoad() {
			uni.showLoading({
				title: '加载中...',
				mask: true
			});
			this.isccccc = uni.getStorageSync("isccccc");
			let systemInfo = uni.getSystemInfoSync();
			let statusBarHeight = systemInfo.windowHeight - (systemInfo.statusBarHeight + uni.upx2px(88))-uni.upx2px(0) - 10;
			this.viewitwm = statusBarHeight + "px";
			console.log("systemInfo", systemInfo)
		},
		onShow() {
			let that = this;
			if (this.$options.filters.isLogin("auth")) {
				this.dataList()
			} else {
				uni.showModal({
					title: "提示",
					content: "检测到您的账号还未登录,是否去登录？",
					confirmColor: this.$lightColor,
					success: function(res) {
						if (res.confirm) {
							that.$options.filters.navigateToLogin();
						} else if (res.cancel) {
							uni.navigateBack();
						}
					},
				});
			}

		},
		onReady() {
			uni.hideLoading()
		},
		methods: {
			changepaixu(index){
				this.currentpaixu = index;
				console.log("changepaixu")
				this.dataList()
			},
			fomatTime(timeLong) {
				let now = moment()
				let time = moment(timeLong);
				let minute = now.diff(time, "minute");
				let hour = now.diff(time, "hour");
				let day = now.diff(time, "day");
				// if(day==0 && hour==0 && minute<=60){
				// 	return minute+"分钟前"
				// }
				// if(day==0 && hour<=24){
				// 	return hour+"小时"+minute+"分钟前";
				// }
				// if(day<=30){
				// 	return day+"天"+hour+"小时"+minute+"分钟前"
				// }
				return time.format("YYYY-MM-DD HH:mm");
			},
			async getshuliang(){
				let user = storage.getUserInfo();
				let params={};
				let res = await http.request({
					url: "/lili/liQuestionsDetail/wodetiwenhuidashu/"+user.id,
					method: Method.GET,
					needToken: true,
					params
				});
				let shuliang=res.data.result.count;
				
				// this.listpaixu[1]["name"]="未读回复("+shuliang+")"
			},
			async dataList() {
				let user = storage.getUserInfo();
				this.getshuliang()
				let params = {
					pageNumber: this.pageNumber,
					pageSize: this.pageSize,
					sort: "create_time",
					order: "desc",
					userId: user.id,
				}
				let res = await http.request({
					url: "/lili/liQuestions",
					method: Method.GET,
					needToken: true,
					params,
				});
				let data = res.data.result.records || [];
				data = data.filter(item => {
					return !item.deleteFlag
				})
				console.log("showHangyeList", res)
				this.list = [...data]

			},
			detail(obj) {
				uni.navigateTo({
					url: "/pages/verticalnav/question-detail?id=" + obj.id,
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.VerticalNav.nav {
		width: 200upx;
		white-space: initial;
		background-color: #F1F2F3;
	}

	.VerticalNav.nav .cu-item {
		width: 100%;
		text-align: center;

		margin: 0;
		border: none;
		height: 70px;
		position: relative;

		.logo {
			width: 40rpx;
			height: 40rpx;
			margin-top: 30rpx;
		}
	}

	/deep/.nav .cu-item {
		line-height: 30rpx;
	}

	.VerticalNav.nav .cu-item.cur {
		background-color: #ffffff;
	}

	.VerticalNav.nav .cu-item.cur::after {
		content: "";
		width: 8upx;
		height: 100%;
		position: absolute;
		background-color: #FF9240;
		top: 0;
		left: 0upx;
		bottom: 0;

	}

	.VerticalBox {
		display: flex;
	}

	.VerticalMain {
		background-color: #ffffff;
		flex: 1;
		padding: 0 30rpx;

		.cu-list {
			color: #666666;
			font-size: 26rpx;
			line-height: 30rpx;

			.cu-item {
				padding: 20rpx 0;
				border-bottom: 1rpx solid #DBDDE0;

				image {
					width: 70rpx;
					height: 32rpx;
					position: relative;
					top: 8rpx;
					margin-right: 15rpx;
				}

				.qes {
					font-size: 28rpx;
					font-weight: 550;

					line-height: 50rpx;
				}

				.ans {
					margin: 20rpx 0;
				}

				.fuhao {
					margin-left: 42rpx;
					color: #999999;

					.margin-right {
						margin: 0 20rpx 0 10rpx;
					}
				}
			}
		}
	}


	.text-gray {
		color: #888888;
	}
</style>
